﻿using SharpPcap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace Services.Equ.PcapCommunication.Abstract
{
    /// <summary>
    /// 一般操作的抽象类
    /// </summary>
    public abstract class AbstractNormalCommunication : AbstractPcapCommunication<bool>
    {
        protected AbstractNormalCommunication(PhysicalAddress destinationMac, string password, ILiveDevice device) : base(destinationMac, password, device)
        {
            ReciveBreak = 1;
        }

        public override bool IsResponse(byte[] bytes)
        {
            if (bytes.Length >= 96)
            {
                if (base.IsResponse(bytes))
                {
                    return bytes[77] == 5 && (bytes[79] == 1 || bytes[79] == 2);
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        public override bool ConvertData2Result(byte[] bytes)
        {
            return bytes[79] == 1;
        }
    }
}
